<%= javascript_include_tag 'prototype', 'scriptaculous', 'lightbox'%>
<%= stylesheet_link_tag 'lightbox'%>
<h1>Listing images - <%= @tag ? "Tag: " + @tag.name : "Group:"%>
    <%= @group? editable_content(
                :content => {
                    :element => 'span',
                    :text => @group.name,
                    :options => {
                        :id => "group_name_edit_#{@group.id}",
                        :class => 'editable-content'
                    }
                },
                :url => {
                    :controller => 'groups',
                    :action => 'update_ajax',
                    :id => @group.id,
                    :field_name => 'name'
                },
                :ajax => {
                    :okButton => false,
                    :cancelLink => false,
                    :submitOnBlur => true,
                    :onFailure => 'function(transport){flash_message(transport.responseText)}',
                    :size => 18,
                    :ajaxOptions => '{evalScripts: true}'
                }
    ) : ""%>
</h1>

<% if @images.empty? %>
    <p>You don't have any image. Why not start uploading some?</p>
<% end%>

<div id="images_container">
<% for image in @images %>
    <div id="image_cell_<%=image.id%>" class="image_cell">
        <div class="image_box">
            <a class="shortcut_image_link" title="<%=h image.name%>" rel="lightbox_dbl[slideshow]" ondblclick="return false;" id="image_link_<%=image.id%>" href="/pictures/<%=image.large_file%>" onclick="image_controller.toggle_batch(<%=image.id%>);return false;">
                <img src="/pictures/<%=image.small_file%>" />
            </a>
        </div>
        <p class="image_name">
        <%= editable_content(
                :content => {
                    :element => 'span',
                    :text => image.name,
                    :options => {
                        :id => "image_name_edit_#{image.id}",
                        :class => 'editable-content'
                    }
                },
                :url => {
                    :controller => 'images',
                    :action => 'update_ajax',
                    :id => image.id,
                    :field_name => 'name'
                },
                :ajax => {
                    :okButton => false,
                    :cancelLink => false,
                    :submitOnBlur => true,
                    :onFailure => 'function(transport){flash_message(transport.responseText)}',
                    :size => 12,
                    :ajaxOptions => '{evalScripts: true}'
                }
            )%>
        </p>
        <p class="image_action">
            <%= link_to_remote 'Delete', :url => {:controller => 'images',:action => 'destroy', :id => image.id }, :update => 'image_controller_space', :confirm => 'Are you sure?', :class=>"delete_link" %>
            <%= link_to 'Show', {:controller => 'images', :action => 'show', :id => image}%>
        </p>
    </div>
<% end %>
</div>
<div class="clear"></div>
<span class="pagination_links">
<%= link_to 'Previous page', { :page => @image_pages.current.previous } if @image_pages.current.previous %>
<%= link_to 'Next page', { :page => @image_pages.current.next } if @image_pages.current.next %>
</span>
